home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / tcp_ip / rip2 / iface.h < prev    next >
C/C++ Source or Header  |  1993-08-16  |  6KB  |  173 lines

  1. #ifndef    _IFACE_H
  2. #define    _IFACE_H
  3.  
  4. #ifndef    _GLOBAL_H
  5. #include "global.h"
  6. #endif
  7.  
  8. #ifndef    _MBUF_H
  9. #include "mbuf.h"
  10. #endif
  11.  
  12. #ifndef _PROC_H
  13. #include "proc.h"
  14. #endif
  15.  
  16. /* Interface encapsulation mode table entry. An array of these structures
  17.  * are initialized in config.c with all of the information necessary
  18.  * to attach a device.
  19.  */
  20.  
  21. #ifdef __GNUC__
  22. struct iface;         /* forward declaration for gcc */
  23. #endif
  24.  
  25. #ifdef LINUX
  26. #ifndef send
  27. /* ugly hack to avoid both libc collisions and jnos misconnections */
  28. #include "socket.h"
  29. #endif
  30. #endif
  31.  
  32. struct iftype {
  33.     char *name;        /* Name of encapsulation technique */
  34.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  35.                 /* Routine to send an IP datagram */
  36.     int (*output) __ARGS((struct iface *,char *,char *,int16,struct mbuf *));
  37.                 /* Routine to send link packet */
  38.     char *(*format) __ARGS((char *,char *));
  39.                 /* Function that formats addresses */
  40.     int (*scan) __ARGS((char *,char *));
  41.                 /* Reverse of format */
  42.     int type;        /* Type field for network process */
  43.     int hwalen;        /* Length of hardware address, if any */
  44. };
  45. #define    NULLIFT    (struct iftype *)0
  46. extern struct iftype Iftypes[];
  47.  
  48.  
  49. /* Interface control structure */
  50. struct iface {
  51.     struct iface *next;    /* Linked list pointer */
  52.     char *name;        /* Ascii string with interface name */
  53.     char *descr;    /* Description of interface */
  54.  
  55.     int32 addr;        /* IP address */
  56.     int32 broadcast;    /* Broadcast address */
  57.     int32 netmask;        /* Network mask */
  58.  
  59.     int16 mtu;        /* Maximum transmission unit size */
  60. #ifdef AX25
  61.     int16 paclen;   /* AX.25 paclen, if applicable */
  62. #endif
  63.  
  64.     int32 flags;        /* Configuration flags */
  65. #define DATAGRAM_MODE   0   /* Send datagrams in raw link frames */
  66. #define    CONNECT_MODE    1    /* Send datagrams in connected mode */
  67. #define IS_NR_IFACE     2   /* Activated for NET/ROM - WG7J */
  68. #define NR_VERBOSE      4   /* NET/ROM broadcast is verbose - WG7J */
  69. #define IS_CONV_IFACE   8   /* Activated for conference call access - WG7J */
  70. #define AX25_BEACON     16  /* Broadcast AX.25 beacons */
  71. #define MAIL_BEACON     32  /* Send MAIL beacons */
  72. #define HIDE_PORT       64  /* Don't show port in mbox P command */
  73. #define AX25_DIGI       128 /* Allow digipeating */
  74. #define ARP_EAVESDROP   256 /* Listen to ARP replies */
  75. #define ARP_KEEPALIVE   512 /* Keep arp entries alive after timeout */
  76. #define LOG_AXHEARD    1024 /* Do ax.25 heard logging on this interface */
  77. #define LOG_IPHEARD    2048 /* Do IP heard logging on this interface */
  78. #define NO_AX25        4096 /* No ax.25 mbox connections on this port */
  79. #define BBS_ONLY       8192 /* BBS's only in mbox via this port */
  80. #define USERS_ONLY     16384 /* Users only on this port */
  81. #define SYSOP_ONLY     32768 /* Sysops only on this port */
  82.  
  83. #ifdef NETROM
  84.     int quality;            /* Netrom interface quality */
  85. #endif
  86.  
  87.     int16 trace;        /* Trace flags */
  88. #define    IF_TRACE_OUT    0x01    /* Output packets */
  89. #define    IF_TRACE_IN    0x10    /* Packets to me except broadcast */
  90. #define    IF_TRACE_ASCII    0x100    /* Dump packets in ascii */
  91. #define    IF_TRACE_HEX    0x200    /* Dump packets in hex/ascii */
  92. #define    IF_TRACE_NOBC    0x1000    /* Suppress broadcasts */
  93. #define    IF_TRACE_RAW    0x2000    /* Raw dump, if supported */
  94.     char *trfile;        /* Trace file name, if any */
  95.     FILE *trfp;        /* Stream to trace to */
  96.  
  97.     struct iface *forw;    /* Forwarding interface for output, if rx only */
  98.  
  99.     struct proc *rxproc;    /* Receiver process, if any */
  100.     struct proc *txproc;    /* Transmitter process, if any */
  101.     struct proc *supv;    /* Supervisory process, if any */
  102.  
  103.     /* Device dependant */
  104.     int dev;        /* Subdevice number to pass to send */
  105.                 /* To device -- control */
  106.     int32 (*ioctl) __ARGS((struct iface *,int cmd,int set,int32 val));
  107.                 /* From device -- when status changes */
  108.     int (*iostatus) __ARGS((struct iface *,int cmd,int32 val));
  109.                 /* Call before detaching */
  110.     int (*stop) __ARGS((struct iface *));
  111.     char *hwaddr;        /* Device hardware address, if any */
  112. #ifdef AX25
  113.     char *cdigi;        /* Crossband digipeater call */
  114. #ifdef MAILBOX
  115.     char *bbscall;      /* AX.25 bbs call, if any */
  116. #endif
  117.     char *bctext;       /* AX.25 beacon text */
  118. #endif
  119.  
  120.     /* Encapsulation dependant */
  121.     void *edv;        /* Pointer to protocol extension block, if any */
  122.     int type;        /* Link header type for phdr */
  123.     int xdev;        /* Associated Slip or Nrs channel, if any */
  124.     int port;        /* Sub port for multy port kiss */
  125.     struct iftype *iftype;    /* Pointer to appropriate iftype entry */
  126.  
  127.             /* Encapsulate an IP datagram */
  128.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  129.             /* Encapsulate any link packet */
  130.     int (*output) __ARGS((struct iface *,char *,char *,int16,struct mbuf *));
  131.             /* Send raw packet */
  132.     int (*raw)        __ARGS((struct iface *,struct mbuf *));
  133.             /* Display status */
  134.     void (*show)        __ARGS((struct iface *));
  135.  
  136.     int (*discard)        __ARGS((struct iface *,struct mbuf *));
  137.     int (*echo)        __ARGS((struct iface *,struct mbuf *));
  138.  
  139.     /* Counters */
  140.     int32 ipsndcnt;     /* IP datagrams sent */
  141.     int32 rawsndcnt;    /* Raw packets sent */
  142.     int32 iprecvcnt;    /* IP datagrams received */
  143.     int32 rawrecvcnt;    /* Raw packets received */
  144.     int32 lastsent;        /* Clock time of last send */
  145.     int32 lastrecv;        /* Clock time of last receive */
  146. };
  147. #define    NULLIF    (struct iface *)0
  148. extern struct iface *Ifaces;    /* Head of interface list */
  149. extern struct iface  Loopback;    /* Optional loopback interface */
  150. extern struct iface  Encap;    /* IP-in-IP pseudo interface */
  151.  
  152. /* Header put on front of each packet in input queue */
  153. struct phdr {
  154.     struct iface *iface;
  155.     unsigned short type;    /* Use pktdrvr "class" values */
  156. };
  157. extern char Noipaddr[];
  158. extern struct mbuf *Hopper;
  159.  
  160. /* In iface.c: */
  161. struct iface *if_lookup __ARGS((char *name));
  162. struct iface *ismyaddr __ARGS((int32 addr));
  163. int if_detach __ARGS((struct iface *ifp));
  164. int setencap __ARGS((struct iface *ifp,char *mode));
  165. char *if_name __ARGS((struct iface *ifp,char *comment));
  166. int bitbucket __ARGS((struct iface *ifp,struct mbuf *bp));
  167. int mask2width __ARGS((int32 mask));
  168.  
  169. /* In config.c: */
  170. int net_route __ARGS((struct iface *ifp,int type,struct mbuf *bp));
  171.  
  172. #endif    /* _IFACE_H */
  173.